<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller 
{
    public function index(){

        if(IS_POST){
            $online=I('online');
          
             $admin=D('admin');
            if($admin->create($_POST,4)){
                if($admin->login()){
                  if($online == 1){
                    $this->success('登录中...',U('Index/index'));
                  }else{
                    $this->success('登录中...',U('Index/index-l'));
                  }
                }else{
                    $this->error('用户名或密码错误！');
                }
            }else{
                $this->error($admin->getError());
            }
            return;
        }
        $this->display();
    }

    // 验证码
    public function verify(){
      $config =    array(
          'fontSize'    =>    30,    // 验证码字体大小
          'length'      =>    3,     // 验证码位数
          'useNoise'    =>    false, // 关闭验证码杂点
          'codeSet'    =>    '0123456789', // 纯数字
      );
      $Verify = new \Think\Verify($config);
      $Verify->entry();
    }
    // 退出
    public function logout(){
      session(null);
      $this->success('退出成功！',U('Login/index'));
    }

    











}